import {
  TokenRequestData,
  TableResponseData,
  returnLocationType,
  feeRulesType
} from '@/types/interface'
import { StoreStatus, DepositType, AllowChangeBattery, RentTimeType } from '@/types/enum'
import { queryBoxTableCol } from '@/api/cabinet/types/cabinet'
import {
  BikePackageDetailOrderTableCol,
  bikeShortTermDetailOrderTableCol,
  BatteryPackageDetailOrderTableCol,
  bikeModifieldsDetailOrderTableCol,
  batterySwapDetailOrderTableCol
} from '@/api/user/types/user'
import { queryBikeProductTableCol } from '@/api/term/types/term'
export interface queryStoreRequestData extends TokenRequestData {
  name: string
  phone: string
  storeName: string
  status: StoreStatus
}

export type queryStoreRequest = ApiResponseData<queryStoreRequestData>

export interface StoreTableCol {
  address: string
  bikeLongTermCount: number
  bikeLongTermProductsCount: number
  boxCount: number
  activityCount: number
  rentOrderCount: number
  cityName: string
  contactPerson: string
  contactPhone: string
  createdTime: string
  /** 入驻人 */
  franchiser: string
  image?: null | string
  imageUrls: string
  latitude: null | number
  longtitude: null | number
  merchantId: number | string
  pickMethod?: string
  serviceTime: string
  status: StoreStatus
  storeId: string | number
  storeName: string
  storeStatus: string
  updatedTime: string
  maxProductCount: string
}
export type queryStoreResponseData = TableResponseData<StoreTableCol>

export type queryStoreResponse = ApiResponseData<queryStoreResponseData>
/**
 * 根据名称获取门店列表
 */
export interface findStoreByNameRequestData extends TokenRequestData {
  storeName: string
}

export type findStoreByNameResponseData = StoreTableCol[]
export type findStoreByNameResponse = ApiResponseData<findStoreByNameResponseData>

/**
 * 获取短租配置
 */
export interface queryBikeShortTermProductRequestData extends TokenRequestData {
  storeId: string
}

export interface BikeShortTermProductType {
  storeId: string //门店ID
  name: string //配置名称
  shortName: string
  price: string //单价
  allowChangeBattery: AllowChangeBattery //是否可以免费换电 0/否，1/是
  deposit: string //押金
  dispatchFee: string //强制还车费
  forceReturn: number //是否可以强制还车
  productDescription: string //配置描述
  supportDepositTypes: DepositType //支持的免押类型，支付宝/微信(暂无)
}

export interface queryBikeShortTermProductResponseData {
  product: BikeShortTermProductType[]
  returnLocation: returnLocationType[]
  feeRuleDetail: feeRulesType[]
}

export type queryBikeShortTermProductResponse =
  ApiResponseData<queryBikeShortTermProductResponseData>

/**
 * 根据加盟商ID查询旗下门店
 * @param merchantId - 加盟商Id
 */
export interface findStoreRequestData extends TokenRequestData {
  merchantId: string
}

export interface findStoreResponseData {
  bikeLongTermCount: number
  bikeLongTermProductsCount: number
  shortBikeCount: number
  activityCount: number
  boxCount: number
  rentOrderCount: number
  status: string
  storeInfo: StoreTableCol
}

export type findStoreResponse = ApiResponseData<findStoreResponseData[]>

/**
 * 查询门店订单
 * @param orderStatus - 订单状态 0 不限 1 待确认 2 租用中 3 已完结
 */
export interface queryStoreOrderRequestData extends TokenRequestData {
  storeId: string
  phone: string
  orderId: string
  orderStatus: '0' | '1' | '2' | '3'
}
export type queryStoreOrderTableCol =
  | BikePackageDetailOrderTableCol
  | bikeShortTermDetailOrderTableCol
  | BatteryPackageDetailOrderTableCol
  | bikeModifieldsDetailOrderTableCol
  | batterySwapDetailOrderTableCol
export type queryStoreOrderResponseData = TableResponseData<queryStoreOrderTableCol>

export type queryStoreOrderResponse = ApiResponseData<queryStoreOrderResponseData>

/**
 * 查询门店换电柜
 */
export interface queryStoreBoxRequestData extends TokenRequestData {
  storeId: string
  boxCode: string
}
export type queryStoreBoxTableCol = queryBoxTableCol
export type queryStoreBoxResponseData = TableResponseData<queryStoreBoxTableCol>
export type queryStoreBoxResponse = ApiResponseData<queryStoreBoxResponseData>

/** 查询门店车辆租赁套餐 */
export interface queryStoreProductRequestData extends TokenRequestData {
  storeId: string
  rentTime: RentTimeType | ''
  pageNum: number
  pageSize: number
  depositType: DepositType | ''
}
export type queryStoreProductTableCol = queryBikeProductTableCol
export type queryStoreProductResponseData = queryStoreProductTableCol[]
export type queryStoreProductResponse = ApiResponseData<queryStoreProductResponseData>

/** 查询门店活动 */
export interface queryStoreActivityRequestData extends TokenRequestData {
  storeId: string
}

export interface queryStoreActivityTableCol {
  name: string
  amount: string
  tags: string
  description: string
}

export type queryStoreActivityResponseData = TableResponseData<queryStoreActivityTableCol>

export type queryStoreActivityResponse = ApiResponseData<queryStoreActivityResponseData>
